// 轮播图点击事件
var btnList = document.querySelectorAll('.btn a')
var lunbo = document.querySelector('.topLunbo')
var liList = document.querySelectorAll('.top .headBar li a')
var aList = document.querySelectorAll('.top .user li a')
var index = 0
for (let i = 0; i < btnList.length; i++) {
    btnList[i].onclick = function(){
        //排他
        index = i
        for (let j = 0; j < btnList.length; j++) {
            btnList[j].className = ''
        }
        this.className = 'cur'
        //换对应的背景图
        lunbo.style.background = "url(/ebeecake/img/banner"+(index+1)+".jpg) center center no-repeat"
        //判断颜色
        if(index === 0){
            // console.log(liList);
            for (let k = 0; k < liList.length; k++) {
                liList[k].style.color = '#fff'
            }
            for (let p = 0; p < aList.length; p++) {
                aList[p].style.color = '#fff'
            }
        }else{
            for (let k = 0; k < liList.length; k++) {
                liList[k].style.color = 'rgb(60, 35, 20)'
            }
            for (let p = 0; p < aList.length; p++) {
                aList[p].style.color = 'rgb(60, 35, 20)'
            }
        }
    }
}

setInterval(function(){
    // console.log(index);
    if(index === 3){
        index = 0
    }else{
        index++
    }
    lunbo.style.background = "url(/ebeecake/img/banner"+(index+1)+".jpg) center center no-repeat"
    for (let j = 0; j < btnList.length; j++) {
        btnList[j].className = ''
    }
    btnList[index].className = 'cur'
    //判断颜色
    if(index === 0){
        // console.log(liList);
        for (let k = 0; k < liList.length; k++) {
            liList[k].style.color = '#fff'
        }
        for (let p = 0; p < aList.length; p++) {
            aList[p].style.color = '#fff'
        }
    }else{
        for (let k = 0; k < liList.length; k++) {
            liList[k].style.color = 'rgb(60, 35, 20)'
        }
        for (let p = 0; p < aList.length; p++) {
            aList[p].style.color = 'rgb(60, 35, 20)'
        }
    }
    // console.log(index);
},5000)

// 人气推荐
var rqliList = document.querySelectorAll('.recommend .bottom li')
var rqimgList = document.querySelectorAll('.recommend .bottom li a .bigImg')

for (let i = 0; i < rqliList.length; i++) {
    rqliList[i].onmouseover = function(){
        rqimgList[i].style.opacity = 1
        rqimgList[i].style.transform = 'scale(1.2,1.2)'
        this.style.boxShadow = '#ccc 0px 0px 20px'
    }
    rqliList[i].onmouseout = function(){
        rqimgList[i].style.opacity = 0
        rqimgList[i].style.transform = ''
        this.style.boxShadow = ''
    }
}

// 视频播放
var music = document.querySelector('.recommend .bottom_sj li .music')
var video = document.querySelector('.video')
var video_mp4 = document.querySelector('.video video')
var box_X = document.querySelector('.video .box_X')

music.onclick=function(){
    video.style.display = 'block'
    video_mp4.autoplay = true
    video_mp4.controls = true
}
box_X.onclick=function(){
    video.style.display = 'none'
    video_mp4.autoplay = false
    video_mp4.controls = false
}